package entjava.poker.service;

import java.util.ArrayList;

import entjava.poker.model.Player;

public class SmallBigService {
	
	private ArrayList<Player> pl; 
	private int smallBlind; 	//small blind number
	private int bigBlind;		//big blind number
	private int dealerNumber; 	//next dealer 
	private Player smallPlayer, bigPlayer, dealerPlayer;
	
	public SmallBigService(ArrayList<Player> play){
		this.pl=play;
		this.dealerNumber=0;
		this.smallBlind=1;
		this.bigBlind=2;
	}

	public void resetGame(ArrayList<Player> ls){
		this.pl=ls;
		  for(int i = 0; i < ls.size(); i++){
	    		ls.get(i).setBet(0);
	    		ls.get(i).setHasCheck(false);
	    		ls.get(i).setWinner(false);
	    		ls.get(i).setHasFolded(false);
	    //		ls.get(i).getHand().getCardList()[i]=null;	 //cards remove from player's card list.
	        	ls.get(i).getHand().setCom("");
	        	ls.get(i).getHand().setCount(0);
	        	ls.get(i).getHand().setRankScore(0);
			  }	
		  nextDealer();
		  nextSmallBlind();
		  nextBigBlind();
		  
		  for(int i = 0; i < ls.size(); i++){
			  for(int j = 0; j < 7; j++){
				  ls.get(i).getHand().getCardList()[j]=null;
			  }
		  }
	}
	
	public void nextDealer(){
		
		if(this.getDealerNumber()<pl.size()-1){
			this.setDealerNumber(getDealerNumber()+1);
		}else{
			this.setDealerNumber(0);
		}
	}
	
	public void nextSmallBlind(){
		
		if(this.getSmallBlind()<pl.size()-1){
			this.setSmallBlind(getSmallBlind()+1);
		}else{
			this.setSmallBlind(0);
		}
	}
	
	public void nextBigBlind(){
		
		if(this.getBigBlind()<pl.size()-1){
			this.setBigBlind(getBigBlind()+1);	
		}else{
			this.setBigBlind(0);
		}
	}

	public ArrayList<Player> getPl() {
		return pl;
	}

	public void setPl(ArrayList<Player> pl) {
		this.pl = pl;
	}

	public int getSmallBlind() {
		return smallBlind;
	}

	public void setSmallBlind(int smallBlind) {
		this.smallBlind = smallBlind;
	}

	public int getBigBlind() {
		return bigBlind;
	}

	public void setBigBlind(int bigBlind) {
		this.bigBlind = bigBlind;
	}

	public int getDealerNumber() {
		return dealerNumber;
	}

	public void setDealerNumber(int dealerNumber) {
		this.dealerNumber = dealerNumber;
	}
	

}
